# $Id: $
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Maxime de Roucy <maxime.deroucy@gmail.com>
# Contributor: Darwin Bautista <djclue917@gmail.com>

pkgname=gsm
pkgver=1.0.17
pkgrel=1
pkgdesc="Shared libraries for GSM 06.10 lossy speech compression"
arch=('i686' 'x86_64')
url="http://www.quut.com/gsm/"
license=('custom')
depends=('glibc')
source=("http://www.quut.com/${pkgname}/${pkgname}-${pkgver}.tar.gz" gsm-shared.patch)
sha256sums=('855a57d1694941ddf3c73cb79b8d0b3891e9c9e7870b4981613b734e1ad07601'
            '1b9fabd7da83a688fc0e5ec712d53c428ff5575b1d5feac8437283ade1448c2b')

prepare() {
  cd ${pkgname}-${pkgver%.*}-pl${pkgver##*.}

  patch -p0 -i ../gsm-shared.patch
}

build() {
  cd ${pkgname}-${pkgver%.*}-pl${pkgver##*.}

  make CCFLAGS="-c ${CFLAGS} -fPIC"
}

package() {
  cd ${pkgname}-${pkgver%.*}-pl${pkgver##*.}

  # Prepare directories
  install -m755 -d "${pkgdir}"/usr/{bin,lib,include/gsm,share/{licenses/${pkgname},man/man{1,3}}}

  make -j1 INSTALL_ROOT="${pkgdir}/usr" \
    GSM_INSTALL_INC="${pkgdir}/usr/include/gsm" \
    GSM_INSTALL_MAN="${pkgdir}/usr/share/man/man3" \
    TOAST_INSTALL_MAN="${pkgdir}/usr/share/man/man1" \
    install

  # Install license
  install -m644 COPYRIGHT ${pkgdir}/usr/share/licenses/${pkgname}/license.txt
}
